package com.easyJava.builder;

import com.easyJava.utils.BufferedWriterUtils;
import com.easyJava.utils.StringUtils;

import java.io.BufferedWriter;
import java.io.IOException;

public class BuildComment {
    public static void createClassComment(BufferedWriterUtils bw, String comment) throws IOException {
        bw.write("/**");
        bw.write(" * " + comment);
        bw.write(" */");
    }

    public static void createFieldComment(BufferedWriterUtils bw, String comment) throws IOException {
        if(comment == null || comment.equals("")) return;

        bw.write("\t/**");
        bw.write("\t * " + comment);
        bw.write("\t */");
    }

    public static void createMethodComment(BufferedWriterUtils bw, String comment) throws IOException {
        bw.write("\t/**");
        bw.write("\t * " + comment);
        bw.write("\t */");
    }

    public static void createXmlComment(BufferedWriterUtils bw, String comment, int indentNum) throws IOException {
        if(StringUtils.isEmpty(comment)) return;
        for(int i = 0; i<indentNum; i++){
            bw.getBufferedWriter().write("\t");
        }
        bw.write("<!-- " + comment + " -->");
    }
}
